package com.wzu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wzu.entity.MedicalCard;
import com.wzu.mapper.MedicalCardMapper;
import com.wzu.service.MedicalCardService;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class MedicalCardServiceImpl extends ServiceImpl<MedicalCardMapper, MedicalCard> implements MedicalCardService {
    @Override
    public List<MedicalCard> searchMedicalCard(String ruralCardNo, String cardId, String diseaseName) {
        QueryWrapper<MedicalCard> wrapper = new QueryWrapper<>();
        if (ruralCardNo != null && !ruralCardNo.isEmpty()) {
            wrapper.like("rural_card_no", ruralCardNo);
        }
        if (cardId != null && !cardId.isEmpty()) {
            wrapper.like("card_id", cardId);
        }
        if (diseaseName != null && !diseaseName.isEmpty()) {
            wrapper.eq("disease_name", diseaseName);
        }
        return list(wrapper);
    }
    @Override
    public boolean addMedicalCard(MedicalCard medicalCard) {
        return save(medicalCard);
    }
    @Override
    public boolean updateMedicalCard(MedicalCard medicalCard) {
        return updateById(medicalCard);
    }
    @Override
    public boolean deleteMedicalCard(Integer id) {
        return removeById(id);
    }
} 